import java.util.ArrayList;
import java.util.List;

/**
 * @Author : lizhifeng
 * @create 2022/8/14 19:37
 * @DESC 2022/8/14 19:37
 */


public class BlockChain {

    private BlockChain() {

    }

    private List<Block> blockList = new ArrayList<>();

    private static final BlockChain blockChain = new BlockChain();

    public static BlockChain getInstance() {
        return blockChain;
    }


    public void addBlock(Block block) {
        blockList.add(block);
    }


    public void printBlockChain() {

        int i = 0;

        for (Block block : blockList) {

            System.out.println("----------------------------------------------------Block--" + String.format("%06d", i++) + "---------------------------------------------------------------------------------------------------");
            Header header = block.getHeader();
            System.out.println(header.toString());
            System.out.println();
            System.out.println("TransactionList=====" + block.getBlockListString());
            System.out.println("----------------------------------------------------------------------------------------------------------------------------------------------------------------------");
            System.out.println();
            System.out.println();

        }

    }

}
